import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@/views/Home'
import Index from '@/pages/index'
// import Order from '@/views/Order'
const Order = () => import('@/views/Order')
// import Product from '@/pages/index/product'
const Product = () => import('@/pages/index/product')

// import Detail from '@/pages/index/detail'
const Detail = () => import('@/pages/index/detail')

// import Cart from '@/pages/cart'
const Cart = () => import('@/pages/cart')

// import OrderList from '@/pages/orderList'
const OrderList = () => import('@/pages/orderList')

// import OrderConfirm from '@/pages/orderList/orderConfirm'
const OrderConfirm = () => import('@/pages/orderList/orderConfirm')

// import OrderPay from '@/pages/orderList/orderPay'
const OrderPay = () => import('@/pages/orderList/orderPay')

// import AliPay from '@/pages/orderList/aliPay'
const AliPay = () => import('@/pages/orderList/aliPay')

// import Login from '@/pages/login'
const Login = () => import('@/pages/login')

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: Home,
    redirect: '/index',
    children: [
      {
        path: '/index',
        name: 'index',
        component: Index
      },
      {
        path: '/product/:id',
        name: 'product',
        component: Product
      },
      {
        path: '/detail/:id',
        name: 'detail',
        component: Detail
      }
    ]
  },
  {
    path: '/cart',
    name: 'cart',
    component: Cart
  },
  {
    path: '/order',
    name: 'order',
    component: Order,
    children: [
      {
        path: 'list',
        name: 'order-list',
        component: OrderList
      },
      {
        path: 'confirm',
        name: 'order-confirm',
        component: OrderConfirm
      },
      {
        path: 'pay',
        name: 'order-pay',
        component: OrderPay
      },
      {
        path: 'alipay',
        name: 'alipay',
        component: AliPay
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: Login
  }

  // {
  //   path: '/about',
  //   name: 'About',
  //   component: () =>
  //     import(/* webpackChunkName: "about" */ '../views/About.vue')
  // }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
